import re
# content = 'hello 1234567 world_this is a regex demo'

# print(len(content))
# 常规匹配
# res = re.match('^hello\s\d\d\d\s\d{4}\s\w{10}.*demo$', content)
# print(res)
# print(res.group())
# print(res.span())
# 泛匹配
# res = re.match('^hello.*demo$', content)
# print(res)
# 匹配目标
# res = re.match('^hello\s(\d+\s\d+)\sworld.*demo$',content)
# print(res)
# print(res.group(1))
# 贪婪模式就是'.*'匹配尽可能多的字符
# res = re.match('^.*(\d+).*$', content)
# print(res)
# print(res.group(1))
# # 非贪婪模式就是'.*?'匹配尽可能少的字符
# res = re.match('^.*?(\d+).*$', content)
# print(res)
# print(res.group(1))
# 匹配模式,就是有换行的话要用re.S
# content = """hello 123
# 任硕 123
# """
# res = re.match('^.*?(\d+).*$', content, re.S)
# print(res)
# print(res.group(1))
# 转义字符,就是用\要专一的字符\
# content = 'the price is $5.00'
# res = re.match('^.*?\$5\.00',content)
# print(res)
# search方法方便
content = 'ren shuo hello 1234567 world_this is a regex demo'
res = re.search('he.*?(\d+).*', content)
print(res)
print(res.group(1))